// source --> http://www.cnkugan.ru/wp-content/plugins/comfortable-reading/js/jquery.comfortable.reading.js?ver=1.1 (function( $ ){ var methods = { init : function( options, initLink ) { $.cookie.json = true; lastSettings = $.cookie('sver-last-options')||{}; var settings = $.extend( { 'base-style' : '', 'default-background' : '#fff', 'default-text-color' : '#000', 'back-link-text' : 'Обычная версия', 'container' : 'body' }, lastSettings, options); $.cookie('sver-last-options',settings, { path: '/' }); if (settings['base-style' ]){ $("head").append($("")); } container = $('
'); $(settings['container']).children().each(function(){ $(this).appendTo(container); }); $(settings['container']).html('').append(container); $.fn.specialVersion('changeParams',settings['default-text-size'],settings['default-text-color'],settings['default-background']); $('
').prependTo('body'); $('
Размер шрифта: AAAA
').appendTo('#special-version-controls'); $('
Цветовая схема: AAA
').appendTo('#special-version-controls'); $('#special-version-controls a').click(function(event){ event.preventDefault(); size=$(this).attr('a-font-size')||false; color=$(this).attr('a-color')||false; bgColor=$(this).attr('a-bg-color')||false; $.fn.specialVersion('changeParams',size,color,bgColor); }); initLink.hide(); backLink = $(initLink).clone().appendTo('#special-version-controls'); backLink.text(settings['back-link-text']).show(); backLink.click(function(event){event.preventDefault(); $.fn.specialVersion('return',backLink, initLink);}); }, bind : function(options) { this.click(function(event){ event.preventDefault(); initLink = $(this); $.cookie('sver-initLinkId', initLink.attr('id'), { path: '/' }); return methods.init(options, initLink); }); }, return : function(backLink, initLink) { $('#special-version-container').children().each(function(){$(this).insertBefore($('#special-version-container'))}) $('#special-version-container').remove(); $('#special-version-base-style').remove(); $('#special-version-controls').remove(); $('*').each(function(){ if ($(this).attr('original-font-size')) $(this).css('font-size',$(this).attr('original-font-size')); if ($(this).attr('original-line-height')) $(this).css('line-height',$(this).attr('original-line-height')); $(this).css('background-color',$(this).attr('original-bg-color')); $(this).css('color',$(this).attr('original-text-color')); }); backLink.remove(); initLink.show(); $.cookie.json = false; $.removeCookie('sver-size', { path: '/' }); $.removeCookie('sver-color', { path: '/' }); $.removeCookie('sver-bgColor', { path: '/' }); $.removeCookie('sver-initLinkId', { path: '/' }); $.removeCookie('sver-last-options', { path: '/' }); }, changeParams : function(size,color,bgColor) { if (size) $.cookie('sver-size', size, { path: '/' }); if (color) $.cookie('sver-color', color, { path: '/' }); if (bgColor) $.cookie('sver-bgColor', bgColor, { path: '/' }); $('#special-version-container *').each(function(){ if (!$(this).attr('original-font-size')) $(this).attr('original-font-size',$(this).css('font-size')); if (!$(this).attr('original-line-height'))$(this).attr('original-line-height',$(this).css('line-height')); }); $('*').each(function(){ if (!$(this).attr('original-bg-color'))$(this).attr('original-bg-color',$(this).css('background-color')); if (!$(this).attr('original-text-color'))$(this).attr('original-text-color',$(this).css('color')); }); if (size){ $('#special-version-container *').each(function(){ if ($(this).css('font-weight')=='bold') $(this).css({'font-size':(Math.round(size*1.2)) + 'px','line-height':Math.round(size*1.4) + 'px'}); else $(this).css({'font-size':size + 'px','line-height':Math.round(size*1.4) + 'px'}); }); } if (color){ $('*').not('#special-version-controls,#special-version-controls *').each(function(){ $(this).css({'color':color}); }); } if (bgColor){ $('*').not('#special-version-controls,#special-version-controls *').each(function(){ $(this).css({'background-color':bgColor}); }); } }, newMethod : function( ) { } }; $.fn.specialVersion = function( method ) { if ( methods[method] ) { return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 )); } else if ( typeof method === 'object' || ! method ) { return methods.bind.apply( this, arguments ); } else { $.error( 'Method named ' + method + ' exists for jQuery.specialVersion' ); } }; })( jQuery ); jQuery( document ).ready(function( $ ) { if($.cookie('sver-initLinkId')&&( $.cookie('sver-size')|| $.cookie('sver-color')|| $.cookie('sver-bgColor'))){ $.fn.specialVersion('init',{ 'default-background' : $.cookie('sver-bgColor'), 'default-text-color' : $.cookie('sver-color'), 'default-text-size' : $.cookie('sver-size') }, $('#'+$.cookie('sver-initLinkId'))); }; }); jQuery( document ).ready( function() { jQuery('#cr_version_link').specialVersion({'base-style' : '/wp-content/plugins/comfortable-reading/css/styles.css'}); }); // source --> http://www.cnkugan.ru/wp-content/plugins/comfortable-reading/js/jquery.cookie.js?ver=1.1 /*! * jQuery Cookie Plugin v1.3.1 * https://github.com/carhartl/jquery-cookie * * Copyright 2013 Klaus Hartl * Released under the MIT license */ (function ($, document, undefined) { var pluses = /\+/g; function raw(s) { return s; } function decoded(s) { return unRfc2068(decodeURIComponent(s.replace(pluses, ' '))); } function unRfc2068(value) { if (value.indexOf('"') === 0) { // This is a quoted cookie as according to RFC2068, unescape value = value.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\'); } return value; } function fromJSON(value) { return config.json ? JSON.parse(value) : value; } var config = $.cookie = function (key, value, options) { // write if (value !== undefined) { options = $.extend({}, config.defaults, options); if (value === null) { options.expires = -1; } if (typeof options.expires === 'number') { var days = options.expires, t = options.expires = new Date(); t.setDate(t.getDate() + days); } value = config.json ? JSON.stringify(value) : String(value); return (document.cookie = [ encodeURIComponent(key), '=', config.raw ? value : encodeURIComponent(value), options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE options.path ? '; path=' + options.path : '', options.domain ? '; domain=' + options.domain : '', options.secure ? '; secure' : '' ].join('')); } // read var decode = config.raw ? raw : decoded; var cookies = document.cookie.split('; '); var result = key ? null : {}; for (var i = 0, l = cookies.length; i < l; i++) { var parts = cookies[i].split('='); var name = decode(parts.shift()); var cookie = decode(parts.join('=')); if (key && key === name) { result = fromJSON(cookie); break; } if (!key) { result[name] = fromJSON(cookie); } } return result; }; config.defaults = {}; $.removeCookie = function (key, options) { if ($.cookie(key) !== null) { $.cookie(key, null, options); return true; } return false; }; })(jQuery, document);